package cn.wenhaha.app.mapping.service.imp;

import cn.wenhaha.app.data.service.DataPluginService;
import cn.wenhaha.app.mapping.bean.vo.TableObject;
import cn.wenhaha.app.mapping.service.TableObjectService;
import cn.wenhaha.datasource.IDataObject;
import cn.wenhaha.datasource.IDataSourcePlugin;
import cn.wenhaha.datasource.Obj;
import cn.wenhaha.datasource.ObjInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 对象 表 相关的接口
 * --------
 *
 * @author ：wyndem
 * @Date ：Created in 2022-05-02 11:21
 */
@Service
public class TableObjectServiceImp implements TableObjectService {

    @Autowired
    private DataPluginService dataPluginService;




    @Override
    public List<Obj> list(String pluginId,String id) {
        IDataSourcePlugin plugin = dataPluginService.getPluginId(pluginId);
        IDataObject dataObject = plugin.getDataObject();
        return dataObject.list(id);
    }

    @Override
    public ObjInfo getAllField(TableObject tableObject) {
        IDataSourcePlugin plugin = dataPluginService.getPluginId(tableObject.getPId());
        IDataObject dataObject = plugin.getDataObject();
        return dataObject.info(tableObject.getNameApi(), tableObject.getAccountId());
    }



}
